// pages/index/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navtil:[
      {
        id:0,
        title:'新品上市',
        img:'/static/images/temp/c1.png'
      },
      {
        id:1,
        title:'新品上市',
        img:'/static/images/temp/c2.png'
      },
      {
        id:2,
        title:'新品上市',
        img:'/static/images/temp/c3.png'
      },
      {
        id:3,
        title:'新品上市',
        img:'/static/images/temp/c4.png'
      },
      {
        id:4,
        title:'新品上市',
        img:'/static/images/temp/c5.png'
      },
      {
        id:5,
        title:'新品上市',
        img:'/static/images/temp/c6.png'
      },
      {
        id:6,
        title:'新品上市',
        img:'/static/images/temp/c7.png'
      },
      {
        id:7,
        title:'新品上市',
        img:'/static/images/temp/c8.png'
      },
    ],
    productlist:[
      {id:0,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate1.jpg'},
      {id:1,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate2.jpg'},
      {id:2,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate3.jpg'},
      {id:3,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate4.jpg'},
      {id:4,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate5.jpg'},
      {id:5,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate6.jpg'},
      {id:6,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate7.jpg'},
      {id:7,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate8.jpg'},
      {id:8,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate9.jpg'},
      {id:9,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate10.jpg'},
      {id:10,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate11.jpg'},
      {id:11,name:'华为mate',price:'￥3099',src:'/static/images/temp/cate12.jpg'},
    ],
    img:[
      {src:'/static/images/temp/banner1.jpg'},
      {src:'/static/images/temp/banner2.jpg'},
      {src:'/static/images/temp/banner3.jpg'},
      {src:'/static/images/temp/banner4.jpg'},
    ]
  },
// 跳转函数
    btnclick(e){
      var id = e.currentTarget.id //获取到当前的id值
      
      
      wx.navigateTo({
        url: `/pages/detail/detail?newObj=${id}`
      })
      
      // 传递一个数组
      // let obj=this.data.productlist
      //JSON.stringify() 方法用于将 值转换为 JSON 字符串
    //encodeURIComponent() 函数可把字符串作为 URI 组件进行编码
    // let newObj=encodeURIComponent(JSON.stringify(obj))
    // var objj = JSON.parse(decodeURIComponent(newObj))
    },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})